-- use_compass.lua
-- created by hunaghr
-- 使用罗盘

return {
    --
    checkEvent = function(eventId, para)
        -- 检查触发
        local petId = para["petId"];
        local dbase = SlimeEventM.query(eventId, "dbase") or {};

        -- 出战史莱姆是否符合
        if dbase.slime ~= petId then
            return false;
        end

        -- 检查次数限制
        local maxTimes = 10;
        if para.times_limit and maxTimes <= BuffDataM.query("compass_gem_bonus", 1) then
            return false;
        end

        -- 检查概率
        local rate = tonumber(SlimeEventM.query(eventId, "condition"));

        local ran = DungeonM.getRandSeed("use_compass") % 1000;
        if rate < ran then
            return false;
        end

        return true;
    end,

    -- 触发事件
    triggerEvent = function(eventId, para)
        -- 奖励
        local bonus = SlimeEventM.calcEventBonus(eventId, para);

        BonusM.doBonus(bonus, "use_compass");
        return true;
    end
};

